package main.gui.workspace;

import java.awt.GridLayout;
import java.util.HashMap;

import javax.swing.JPanel;

import data.EditorObject;
import data.ObjectDatabase;

public class WorkspaceListPanel extends JPanel {

	private static final long serialVersionUID = 1L;

	private static final int NUM_COLUMNS = 5;

	public WorkspaceListPanel(String editorObjectFQClassName) {
		super();

		HashMap<String, EditorObject> objects = ObjectDatabase.getInstance()
				.getAllEditorObjectsOfClass(editorObjectFQClassName);

		GridLayout layout = new GridLayout(
				(int) (objects.size() / NUM_COLUMNS), NUM_COLUMNS);
		layout.setHgap(10);
		layout.setVgap(10);
		this.setLayout(layout);

		for (String s : objects.keySet()) {
			this.add(objects.get(s).buildWorkspaceListItem());
		}
	}

}
